package com.allenkerr.util;

import java.io.File;
import java.util.List;

/**
 * Created by 小柯 on 17/7/6.
 */
public class FileUtils {

    public static void getFilePathList(File dir, List<String> filePathList) {
        if (dir.isFile()) {
            filePathList.add(dir.getAbsolutePath());
            return;
        }

        if (dir.isDirectory()) {
            File[] listFiles = dir.listFiles();
            for (File file : listFiles) {
                if (file.isDirectory()) {
                    //递归
                    getFilePathList(file, filePathList);
                } else if (!".DS_Store".equalsIgnoreCase(file.getName())) {
                    filePathList.add(file.getAbsolutePath());
                }
            }
        }
    }

    public static void getFilePathList(String dirPath, List<String> filePathList) {
        File dir = new File(dirPath);
        getFilePathList(dir, filePathList);
    }

}
